#!/bin/bash

# bc 高级算数工具

echo "4 * 0.56" | bc;

no1=54;
result=`echo "$no1 * 1.5" | bc`;
echo $result;

#设置小数精度
echo "scale=2;3/8" | bc;
echo "3/8" | bc;

#进制转换
no2=100;
result1=`echo "obase=2;$no2" | bc`;
echo ${result1};

result2=`echo "obase=10;ibase=2;$result1" | bc`;
echo ${result2};

#计算平方以及平方根
echo "sqrt(100)" | bc;
echo "10^10" | bc;